package com.lizhe.mybatisplus.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lizhe.mybatisplus.mapper.ArticleMapper;
import com.lizhe.mybatisplus.model.Article;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author lz
 * @create 2021-10-28
 */
@Service
public class ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    // Mybatisplus 自带的方法

    public Article getArticle(Integer id){
        return  articleMapper.selectById(id);
    }

    public int saveArticle(Article article){
        return  articleMapper.insert(article);
    }

    // xml自己写XML的方法
    public int deleteByPrimaryKey(Integer id) {
        return articleMapper.deleteByPrimaryKey(id);
    }


    public int insert(Article record) {
        return articleMapper.insert(record);
    }


    public int insertSelective(Article record) {
        return articleMapper.insertSelective(record);
    }


    public Article selectByPrimaryKey(Integer id) {
        return articleMapper.selectByPrimaryKey(id);
    }


    public int updateByPrimaryKeySelective(Article record) {
        return articleMapper.updateByPrimaryKeySelective(record);
    }


    public int updateByPrimaryKey(Article record) {
        return articleMapper.updateByPrimaryKey(record);
    }

    public Page<Article> findByAll(Page<Article> page, Article article) {
        return articleMapper.findByAll(page,article);
    }
}
